Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass through Lua code in script #495

Merged
merged 28 commits into from
Dec 5, 2017

Conversation

alerque
Copy link
Member

@alerque alerque commented Nov 29, 2017

This allows the literal characters % and balanced pairs of { } to appear in either command (\script{...}) or environment (\begin{script}...\end{script}) forms of the script command and be passed through as-is to Lua for evaluation.

Todo before merging:

  • Make sure we're passing regression tests on everything that used to build.
  • Update documentation to describe new allowed syntax and limitations.
  • Refactor LPEG capture groups or add AST tree cleanup so we're not passing as many arbitrary data types further down the parsing pipeline than we need to be.

This will close #450 and closes #92.

@alerque alerque added this to the v0.9.5 milestone Nov 29, 2017
@alerque
Copy link
Member Author

alerque commented Dec 2, 2017

Hmm it looks like the only reason escape sequences aren't allowed currently is because of something I overlooked in the LPEG grammar. It should be possible to get them working properly so 100% of valid Lua code would be allowed, minus whatever the closing tag (or unmatched closing brace) is.

@alerque
Copy link
Member Author

alerque commented Dec 4, 2017

I updated this to fix handling Lua string escape sequences (and remove the caveat about them from the docs).

@alerque
Copy link
Member Author

alerque commented Dec 4, 2017

Refactoring the LPEG groups is going to be a different kind of job and out of scope for this PR, so I'm nixing that item. It looks like the right way to do that is to compress the tree one more level than it is (so what is now passed around as content[1] from TeXlike function calls becomes just content). This would also normalize the use of functions from Lua vs. from TeX-flavor markup, but that's a major change and I don't see any simpler way of cleaning up the grammar. So I cleaned up the coding style and we'll call it good for this PR.

I've tested this on my own machine and the metrics I get for the current master branch. This doesn't seem to introduce any new regressions.

@alerque alerque mentioned this pull request Dec 4, 2017
8 tasks
@simoncozens simoncozens merged commit 9d910bf into sile-typesetter:master Dec 5, 2017
@alerque alerque deleted the input-anything branch December 5, 2017 07:30
alerque added a commit to alerque/sile that referenced this pull request Dec 28, 2017
With different types of stuff being processed differently (passthrough
in an environment, passthrough in a command, and normal) the "stuff"
category got a more specific name. I missed one place it was referenced.
alerque added a commit that referenced this pull request Dec 28, 2017
With different types of stuff being processed differently (passthrough
in an environment, passthrough in a command, and normal) the "stuff"
category got a more specific name. I missed one place it was referenced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

% in inline scripts \script command interprets braces as grouping operators
2 participants